<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }
        .container {
            background-color: white;
            padding: 20px 30px;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }
        h2 {
            text-align: center;
        }
        input[type="text"], input[type="password"] {
            width: 100%;
            padding: 10px;
            margin-top: 10px;
            border: 1px solid #ccc;
            border-radius: 3px;
        }
        button {
            width: 100%;
            padding: 10px;
            margin-top: 10px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 3px;
            cursor: pointer;
        }
        button:hover {
            background-color: #45a049;
        }
    </style>
</head>
<body>
    <div class="container">
        <h2>注册</h2>
        <input type="text" id="newUsername" placeholder="用户名">
        <input type="password" id="newPassword" placeholder="密码">
        <button onclick="register()">注册</button>
        <p style="text-align:center; margin-top:10px;">
            已有账号？<a href="login.html">登录</a>
        </p>
    </div>

    <script>
        function register() {
            const newUsername = document.getElementById('newUsername').value;
            const newPassword = document.getElementById('newPassword').value;
            if (newUsername && newPassword) {
                localStorage.setItem('username', newUsername);
                localStorage.setItem('password', newPassword);
                alert('注册成功，请登录');
                window.location.href = "login.html";
            } else {
                alert('请输入用户名和密码');
            }
        }
    </script>
</body>
</html>